/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.multioperacion.data;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

/**
 *
 * @author gabrielbran
 */
public class Conexion {

    private static EntityManagerFactory emf;
    private static EntityManager em;

    public Conexion() {
        emf = Persistence.createEntityManagerFactory("AppMultioperacionPU");
        em = emf.createEntityManager();
    }

    public EntityManager getEm() {
        if (em == null || !em.isOpen()) {
            em = emf.createEntityManager();
        }
        return em;
    }
}
